package clientView;

import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.Format;
import java.util.Locale;
import java.util.Vector;

import javax.swing.AbstractButton;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

import object.Company;
import utility.StringUtil;
import clientMain.Main;
import clientUtilGUI.KeyValue;
import clientUtilGUI.UtilityGUI;

import com.toedter.calendar.JDateChooser;

import database.CompanyDelegate;

public class Company_Edit  extends JScrollPane implements ActionListener{
	protected static final Component Company_Edit = null;
	private JTextField txtComIndus;
	private JTextField txtComSL;
	private JTextField txtComPhone;
	private JTextField txtComWebsite;
	private JTextField txtComName;
	/**
	 * @wbp.nonvisual location=11,-31
	 */
	private JButton btnCance;
	private AbstractButton btnSave;
	private int provinceId;
	private JPanel panelBody;
	private JComboBox comboBoxTp;
	private JLabel lblSinThoi;
	private JDateChooser dateStart;
	private JTextField textField_Dc;
	private JLabel lblTnCngTy;
	private Vector<JTextField> groupTxt = new Vector<JTextField>();
	private JComboBox comboBoxType;
	private JLabel lblLoiHnhKinh;
	private JLabel lblNgiSngLp;
	public Format formatter;
	private JLabel lblNmThnhLp;
	private JComboBox comboBoxQuanH;
	private GridBagConstraints gbc_comboBoxQuanH;
	private JLabel lbliaChi;
	private JLabel lblWesite;
	public String minStrBirthday = "01/01/1930";
	
	public Company_Edit(int comId) {	
		setViewportView(initComponet());
		setBorder(new EmptyBorder(0, 0, 0, 0));
	}
	public JPanel initComponet(){
		JPanel panelHeader = new JPanel();
		setColumnHeaderView(panelHeader);
		
		JLabel lblSaThngTin = new JLabel("Sửa Thông Tin Công Ty");

		lblSaThngTin.setFont(UtilityGUI.fontHeader1);
		lblSaThngTin.setForeground(UtilityGUI.colorHeader1);
		panelHeader.add(lblSaThngTin);
		
		panelBody = new JPanel();
		setViewportView(panelBody);
		GridBagLayout gbl_panelBody = new GridBagLayout();
		gbl_panelBody.columnWidths = new int[]{206, 53, 227, 31, 30, 0, 0};
		gbl_panelBody.rowHeights = new int[]{23, 15, 13, 35, 35, 34, 38, 0, 29, 34, 38, 39, 0, 0, 0, 0};
		gbl_panelBody.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gbl_panelBody.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		panelBody.setLayout(gbl_panelBody);
		
		lblTnCngTy = new JLabel("Tên Công Ty :");
		lblTnCngTy.setFont(UtilityGUI.fontLblForm);;
		GridBagConstraints gbc_lblTnCngTy = new GridBagConstraints();
		gbc_lblTnCngTy.anchor = GridBagConstraints.EAST;
		gbc_lblTnCngTy.insets = new Insets(0, 0, 5, 5);
		gbc_lblTnCngTy.gridx = 1;
		gbc_lblTnCngTy.gridy = 1;
		panelBody.add(lblTnCngTy, gbc_lblTnCngTy);
		
		txtComName = new JTextField();
		GridBagConstraints gbc_textField = new GridBagConstraints();
		gbc_textField.gridwidth = 3;
		gbc_textField.insets = new Insets(0, 0, 5, 5);
		gbc_textField.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField.gridx = 2;
		gbc_textField.gridy = 1;
		panelBody.add(txtComName, gbc_textField);
		txtComName.setColumns(10);
		
		JLabel lblNewLabel_1 = new JLabel("*");
		lblNewLabel_1.setFont(UtilityGUI.fontNote);
		lblNewLabel_1.setForeground(Color.RED);
		GridBagConstraints gbc_lblNewLabel_1 = new GridBagConstraints();
		gbc_lblNewLabel_1.insets = new Insets(0, 0, 5, 0);
		gbc_lblNewLabel_1.gridx = 5;
		gbc_lblNewLabel_1.gridy = 1;
		panelBody.add(lblNewLabel_1, gbc_lblNewLabel_1);
		
		JLabel lblNewLabel = new JLabel("Loại Hình :");
		lblNewLabel.setFont(UtilityGUI.fontLblForm);;
		GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
		gbc_lblNewLabel.anchor = GridBagConstraints.EAST;
		gbc_lblNewLabel.insets = new Insets(0, 0, 5, 5);
		gbc_lblNewLabel.gridx = 1;
		gbc_lblNewLabel.gridy = 3;
		panelBody.add(lblNewLabel, gbc_lblNewLabel);
		
		comboBoxType = new JComboBox();
		comboBoxType.setFont(UtilityGUI.fontComboBox);
		comboBoxType.addItem("Nhà Nước");
		comboBoxType.addItem("Tư Nhân");
		GridBagConstraints gbc_comboBoxType = new GridBagConstraints();
		gbc_comboBoxType.gridwidth = 3;
		gbc_comboBoxType.insets = new Insets(0, 0, 5, 5);
		gbc_comboBoxType.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBoxType.gridx = 2;
		gbc_comboBoxType.gridy = 3;
		panelBody.add(comboBoxType, gbc_comboBoxType);
		
	    lblLoiHnhKinh = new JLabel("Lĩnh Vực Kinh Doanh :");
		lblLoiHnhKinh.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblLoiHnhKinh = new GridBagConstraints();
		gbc_lblLoiHnhKinh.anchor = GridBagConstraints.EAST;
		gbc_lblLoiHnhKinh.insets = new Insets(0, 0, 5, 5);
		gbc_lblLoiHnhKinh.gridx = 1;
		gbc_lblLoiHnhKinh.gridy = 4;
		panelBody.add(lblLoiHnhKinh, gbc_lblLoiHnhKinh);
		
		txtComIndus = new JTextField();
		GridBagConstraints gbc_textField_2 = new GridBagConstraints();
		gbc_textField_2.gridwidth = 3;
		gbc_textField_2.insets = new Insets(0, 0, 5, 5);
		gbc_textField_2.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_2.gridx = 2;
		gbc_textField_2.gridy = 4;
		panelBody.add(txtComIndus, gbc_textField_2);
		txtComIndus.setColumns(10);
		
		lblNmThnhLp = new JLabel("Năm Thành Lập :");
		lblNmThnhLp.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblNmThnhLp = new GridBagConstraints();
		gbc_lblNmThnhLp.anchor = GridBagConstraints.EAST;
		gbc_lblNmThnhLp.insets = new Insets(0, 0, 5, 5);
		gbc_lblNmThnhLp.gridx = 1;
		gbc_lblNmThnhLp.gridy = 5;
		panelBody.add(lblNmThnhLp, gbc_lblNmThnhLp);
		
		dateStart = new JDateChooser();
		dateStart.setLocale(new Locale("vi"));
		dateStart.setDateFormatString(Main.strFormatDate);
		dateStart.setFont(new Font("Tahoma", Font.BOLD, 11));
		GridBagConstraints gbc_textField1 = new GridBagConstraints();
		gbc_textField1.gridwidth = 3;
		gbc_textField1.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField1.insets = new Insets(0, 0, 5, 5);
		gbc_textField1.gridx = 2;
		gbc_textField1.gridy = 5;
		panelBody.add(dateStart, gbc_textField1);
		
		lblNgiSngLp = new JLabel("Người Sáng Lập :");
		lblNgiSngLp.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblNgiSngLp = new GridBagConstraints();
		gbc_lblNgiSngLp.anchor = GridBagConstraints.EAST;
		gbc_lblNgiSngLp.insets = new Insets(0, 0, 5, 5);
		gbc_lblNgiSngLp.gridx = 1;
		gbc_lblNgiSngLp.gridy = 6;
		panelBody.add(lblNgiSngLp, gbc_lblNgiSngLp);
		
		txtComSL = new JTextField();
		GridBagConstraints gbc_textField_4 = new GridBagConstraints();
		gbc_textField_4.gridwidth = 3;
		gbc_textField_4.insets = new Insets(0, 0, 5, 5);
		gbc_textField_4.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_4.gridx = 2;
		gbc_textField_4.gridy = 6;
		panelBody.add(txtComSL, gbc_textField_4);
		txtComSL.setColumns(10);
		
		JLabel label = new JLabel("*");
		label.setFont(UtilityGUI.fontNote);
		label.setForeground(Color.RED);
		GridBagConstraints gbc_label = new GridBagConstraints();
		gbc_label.insets = new Insets(0, 0, 5, 0);
		gbc_label.gridx = 5;
		gbc_label.gridy = 6;
		panelBody.add(label, gbc_label);
		
		lbliaChi = new JLabel("Địa Chỉ :");
		lbliaChi.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lbliaChi = new GridBagConstraints();
		gbc_lbliaChi.anchor = GridBagConstraints.EAST;
		gbc_lbliaChi.insets = new Insets(0, 0, 5, 5);
		gbc_lbliaChi.gridx = 1;
		gbc_lbliaChi.gridy = 7;
		panelBody.add(lbliaChi, gbc_lbliaChi);
		
		textField_Dc = new JTextField();
		GridBagConstraints gbc_textField_Dc1 = new GridBagConstraints();
		gbc_textField_Dc1.gridwidth = 3;
		gbc_textField_Dc1.insets = new Insets(0, 0, 5, 5);
		gbc_textField_Dc1.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_Dc1.gridx = 2;
		gbc_textField_Dc1.gridy = 7;
		panelBody.add(textField_Dc, gbc_textField_Dc1);
		textField_Dc.setColumns(10);
		groupTxt.add(textField_Dc);
		
		JLabel lblTinhThanh = new JLabel("Tỉnh Thành :");
		lblTinhThanh.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblTinhThanh = new GridBagConstraints();
		gbc_lblTinhThanh.anchor = GridBagConstraints.EAST;
		gbc_lblTinhThanh.insets = new Insets(0, 0, 5, 5);
		gbc_lblTinhThanh.gridx = 1;
		gbc_lblTinhThanh.gridy = 8;
		panelBody.add(lblTinhThanh, gbc_lblTinhThanh);
		
		comboBoxTp = new JComboBox();
		comboBoxTp = UtilityGUI.getComboBox("Province", 0,"");
		comboBoxTp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(comboBoxTp.getSelectedIndex()==0){
					comboBoxQuanH.setSelectedIndex(0);
					comboBoxQuanH.setEnabled(false);
		    		return;
		    	}
				
		    	provinceId = Integer.parseInt(((KeyValue)comboBoxTp.getSelectedItem()).getKey()); 
		    	comboBoxQuanH.setVisible(false);
		    	comboBoxQuanH =UtilityGUI.getComboBox("District", provinceId,"");
		    	comboBoxQuanH.addActionListener(new ActionListener() {				
					@Override
					public void actionPerformed(ActionEvent arg0) {
					}
				});
		    	panelBody.add(comboBoxQuanH, gbc_comboBoxQuanH);			
			}
		});
		GridBagConstraints gbc_comboBox = new GridBagConstraints();
		gbc_comboBox.gridwidth = 3;
		gbc_comboBox.insets = new Insets(0, 0, 5, 5);
		gbc_comboBox.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBox.gridx = 2;
		gbc_comboBox.gridy = 8;
		panelBody.add(comboBoxTp, gbc_comboBox);
		
		JLabel lblQunHuyn = new JLabel("Quận Huyện :");
		lblQunHuyn.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblQunHuyn = new GridBagConstraints();
		gbc_lblQunHuyn.anchor = GridBagConstraints.EAST;
		gbc_lblQunHuyn.insets = new Insets(0, 0, 5, 5);
		gbc_lblQunHuyn.gridx = 1;
		gbc_lblQunHuyn.gridy = 9;
		panelBody.add(lblQunHuyn, gbc_lblQunHuyn);
		
		comboBoxQuanH = new JComboBox();
		comboBoxQuanH.setEnabled(false);
		comboBoxQuanH.addItem("-- Chọn Quận(huyện) --");
		gbc_comboBoxQuanH = new GridBagConstraints();
		gbc_comboBoxQuanH.gridwidth = 3;
		gbc_comboBoxQuanH.insets = new Insets(0, 0, 5, 5);
		gbc_comboBoxQuanH.fill = GridBagConstraints.HORIZONTAL;
		gbc_comboBoxQuanH.gridx = 2;
		gbc_comboBoxQuanH.gridy = 9;
		panelBody.add(comboBoxQuanH, gbc_comboBoxQuanH);
		
		lblSinThoi = new JLabel("Số Điện Thoại :");
		lblSinThoi.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblSinThoi = new GridBagConstraints();
		gbc_lblSinThoi.anchor = GridBagConstraints.EAST;
		gbc_lblSinThoi.insets = new Insets(0, 0, 5, 5);
		gbc_lblSinThoi.gridx = 1;
		gbc_lblSinThoi.gridy = 10;
		panelBody.add(lblSinThoi, gbc_lblSinThoi);
		
		txtComPhone = new JTextField();
		GridBagConstraints gbc_textField_6 = new GridBagConstraints();
		gbc_textField_6.gridwidth = 3;
		gbc_textField_6.insets = new Insets(0, 0, 5, 5);
		gbc_textField_6.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_6.gridx = 2;
		gbc_textField_6.gridy = 10;
		panelBody.add(txtComPhone, gbc_textField_6);
		txtComPhone.setColumns(10);
		
		lblWesite = new JLabel("Website :");
		lblWesite.setFont(UtilityGUI.fontLblForm);
		GridBagConstraints gbc_lblWesite = new GridBagConstraints();
		gbc_lblWesite.insets = new Insets(0, 0, 5, 5);
		gbc_lblWesite.anchor = GridBagConstraints.EAST;
		gbc_lblWesite.gridx = 1;
		gbc_lblWesite.gridy = 11;
		panelBody.add(lblWesite, gbc_lblWesite);
		
		txtComWebsite = new JTextField();
		GridBagConstraints gbc_textField_7 = new GridBagConstraints();
		gbc_textField_7.gridwidth = 3;
		gbc_textField_7.insets = new Insets(0, 0, 5, 5);
		gbc_textField_7.fill = GridBagConstraints.HORIZONTAL;
		gbc_textField_7.gridx = 2;
		gbc_textField_7.gridy = 11;
		panelBody.add(txtComWebsite, gbc_textField_7);
		txtComWebsite.setColumns(10);
		
		btnSave = new JButton(UtilityGUI.btnSave);
		btnSave.addActionListener(this);
		btnSave.setFont(UtilityGUI.fontBtnForm);
		GridBagConstraints gbc_btnSave = new GridBagConstraints();
		gbc_btnSave.insets = new Insets(0, 0, 5, 5);
		gbc_btnSave.gridx = 3;
		gbc_btnSave.gridy = 12;
		panelBody.add(btnSave, gbc_btnSave);
		
	    btnCance = new JButton(UtilityGUI.btnCancel);
		btnCance.addActionListener(this);
		btnCance.setFont(UtilityGUI.fontBtnForm);
		GridBagConstraints gbc_btnCance = new GridBagConstraints();
		gbc_btnCance.insets = new Insets(0, 0, 5, 5);
		gbc_btnCance.gridx = 4;
		gbc_btnCance.gridy = 12;
		panelBody.add(btnCance, gbc_btnCance);
		
		JLabel lbllu = new JLabel(UtilityGUI.noticeForm);
		lbllu.setFont(UtilityGUI.fontNote);
		lbllu.setForeground(UtilityGUI.colorNote);
		GridBagConstraints gbc_lbllu = new GridBagConstraints();
		gbc_lbllu.fill = GridBagConstraints.HORIZONTAL;
		gbc_lbllu.insets = new Insets(0, 0, 5, 5);
		gbc_lbllu.gridx = 2;
		gbc_lbllu.gridy = 13;
		panelBody.add(lbllu, gbc_lbllu);
		groupTxt.add(txtComName);
		groupTxt.add(txtComPhone);
		groupTxt.add(txtComIndus);
		groupTxt.add(txtComSL);
		return panelBody;
	}

	@Override
	public void actionPerformed(ActionEvent e) {
		if(e.getSource() == btnSave){
			if(!StringUtil.isValidName(txtComName.getText(), 250, 3)){
				txtComName.setText(StringUtil.removeUnwantedSpace(txtComName.getText()));
				JOptionPane.showMessageDialog(null, 
						UtilityGUI.errorValidName(StringUtil.removeColon(lblTnCngTy.getText()), 250, 3),
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				txtComName.requestFocusInWindow();
				txtComName.setBackground(UtilityGUI.txtFocusError);
				return;
		
			}else if(!StringUtil.isValidName(txtComIndus.getText(), 250, 3)){
				JOptionPane.showMessageDialog(null, 
						UtilityGUI.errorValidName(StringUtil.removeColon(lblLoiHnhKinh.getText()), 250, 3),
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				txtComIndus.requestFocusInWindow();
				txtComIndus.setBackground(UtilityGUI.txtFocusError);
				return;
		
			}else if(dateStart.getDate() == null){
				JOptionPane.showMessageDialog(null,"Bạn Phải Chọn Ngày Thành Lập");
				dateStart.requestFocusInWindow();
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				return;
			
			}else if(!StringUtil.isValidName(txtComSL.getText(), 250, 3)){
				JOptionPane.showMessageDialog(null, 
						UtilityGUI.errorValidName(StringUtil.removeColon(lblNgiSngLp.getText()), 250, 3),
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				txtComSL.requestFocusInWindow();
				txtComSL.setBackground(UtilityGUI.txtFocusError);
				return;
		
			}else if(comboBoxTp.getSelectedIndex() == 0){
				comboBoxTp.requestFocusInWindow();
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				return;
				
			}else if(comboBoxQuanH.getSelectedIndex() == 0){
				comboBoxQuanH.requestFocusInWindow();
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				return;
			}else if(!StringUtil.isValidName(textField_Dc.getText(), 250, 3)){
				JOptionPane.showMessageDialog(null, 
						UtilityGUI.errorValidName(StringUtil.removeColon(lbliaChi.getText()), 250, 3),
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				textField_Dc.requestFocusInWindow();
				textField_Dc.setBackground(UtilityGUI.txtFocusError);
				return;
		
			}else if(!StringUtil.isValidPhone(txtComPhone.getText())){
				JOptionPane.showMessageDialog(null, 
						UtilityGUI.errorValid(StringUtil.removeColon(lblSinThoi.getText())),
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				txtComPhone.requestFocusInWindow();
				for(int i = 0; i <groupTxt.size(); i++){
					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
				}
				txtComPhone.setBackground(UtilityGUI.txtFocusError);				
				return;
			
			}
			else if(!StringUtil.isValidName(txtComWebsite.getText(), 250, 3)){
//				JOptionPane.showMessageDialog(null, 
//						UtilityGUI.errorValidName(StringUtil.removeColon(lblWesite.getText()), 250, 3),
//						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
//				for(int i = 0; i <groupTxt.size(); i++){
//					groupTxt.get(i).setBackground(UtilityGUI.txtBlurError);
//				}
//				txtComWebsite.requestFocusInWindow();
//				txtComWebsite.setBackground(UtilityGUI.txtFocusError);
//				return;
//		
			}
			
			String ComName = StringUtil.removeUnwantedSpace(txtComName.getText());
			String ComType = StringUtil.removeUnwantedSpace( (String) comboBoxType.getSelectedItem());
			String ComIndus = StringUtil.removeUnwantedSpace(txtComIndus.getText());
			String Comyear  = StringUtil.removeUnwantedSpace( Main.sdfDate.format(dateStart.getDate()));
			String ComSl = StringUtil.removeUnwantedSpace( txtComSL.getText());
			String ComAddress =  StringUtil.removeUnwantedSpace(textField_Dc.getText());
			int ComCity = Integer.parseInt(((KeyValue)comboBoxTp.getSelectedItem()).getKey());
			String ComPhone =  StringUtil.removeUnwantedSpace(txtComPhone.getText());
			String ComWeb  = StringUtil.removeUnwantedSpace( txtComWebsite.getText());

			
			Company dep = new Company();
			dep.setCompanyId(2);
			dep.setCompanyName(ComName);
			dep.setCompanyType(ComType);
			dep.setCompanyIndustry(ComIndus);
			dep.setCompanyFounded(Comyear);
			dep.setCompanyHeadquarters(ComAddress);
			dep.setCompanyFounder(ComSl);
			dep.setCompanyCity(ComCity);
			dep.setCompanyPhone(ComPhone);
			dep.setCompanyWebsite(ComWeb);
			CompanyDelegate com = new CompanyDelegate();
			if(com.updateCompany(dep, Main.userId)){

				JOptionPane.showMessageDialog(null, UtilityGUI.successAction,
						UtilityGUI.titleAlert, JOptionPane.INFORMATION_MESSAGE);
				this.setVisible(false);
				Main.jTabbedPane.remove(this);
				int index_ComView = Main.jTabbedPane.positionTab(UtilityGUI.tabComView);
				if(index_ComView > -1){
					Main.jTabbedPane.remove(index_ComView);
					Main.jTabbedPane.addTab(new Company_View(), UtilityGUI.tabComView, index_ComView);
				}
				int index_DepList = Main.jTabbedPane.positionTab(UtilityGUI.tabComView);
				if(index_DepList == -1){
					Main.jTabbedPane.addTab(new Company_View(), UtilityGUI.tabComView);
					Main.jTabbedPane.setSelectedIndex(Main.jTabbedPane.getTabCount()-1);
			}
			}else{
				JOptionPane.showMessageDialog(null, UtilityGUI.errorAction, 
						UtilityGUI.titleAlert, JOptionPane.ERROR_MESSAGE);
				return;
			};
			
		
		
		}
		if(e.getSource()== btnCance){
			Main.jTabbedPane.remove(this);
		}
	}

	


}

